Java: Learn Java in 3 Days! (David Chang - Programming ) by David Chang

Java: Learn Java in 3 Days! (David Chang - Programming ) by David Chang

Author:David Chang
Language: eng
Format: azw3, pdf
Published: 2017-07-13T07:00:00+00:00


Nested if…else statement

When you combine multiple if / if-else /if-else-if ladders then lot sequence decisions are involved. You have to take care of program executes, instructions when sequence conditions are encountered.

Example:

public class NestedIf

{

public static void main(String args[])

{

//Declaring a variable a and initializing it with a value 5

int a=3;

//Declaring a variable b and initializing it with a value 3

int b=3;

if(a==5)

{

//This block will be executed only if "a" is equal to 5

if(b==3)

{

/*This block will be executed only if

a is equal to 5 and b is equal to 3 */

System.out.println("Hi, a is 5 and b is 3");



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.